package com.lizonghui.googleplay.base;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

/**
 * Created by Administrator on 2016/6/17.
 * Fragment基类的常规写法
 */
public abstract class BaseFragmentCommon extends Fragment {
    /**
     * 1.放置共有的属性和共有的方法
     * 2.不用关心Fragment相关的生命周期
     * 3.还可以控制哪一个方法是必须实现，哪一个选择性实现
     * @param savedInstanceState
     */
    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
       init();
        super.onCreate(savedInstanceState);
    }




    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        return initView();
    }




    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        initData();
        initListener();
        super.onActivityCreated(savedInstanceState);
    }



    public void init() {
    }

    /**
     * 初始化VIew，必须实现，改成abstract
     * @return
     */
    public abstract View initView();
    public void initData() {
    }
    public void initListener() {
    }

}
